//
//  XRGridTableCell.m
//  XRmenu
//
//  Created by loufq on 11-11-23.
//  Copyright 2011年 foxhis. All rights reserved.
//

#import "XRGridTableCell.h"


@implementation XRGridTableCell
@synthesize btn;
@synthesize delegate;
//=========================================================== 
// dealloc
//=========================================================== 
- (void)dealloc
{
    [btn release];
    btn = nil;
    delegate = nil;
    [super dealloc];
}


-(id)initWithFrame:(CGRect)frame
{
	self = [super initWithFrame:frame];
	
	if (self) { 
        [self addButtonHandle:frame];
	}
	
	return self;
}

-(id) initWithConfig:(NSDictionary *)cfg
{
    self = [super initWithConfig:cfg];
    if (self) {
        [self addButtonHandle:CGRectFromString([cfg getStringValueAtPath:@"view rect"])];
    }
    return self;
}

-(void) addButtonHandle:(CGRect)bframe
{
    self.btn =[UFMultiLineButton buttonWithType:UIButtonTypeCustom];
    self.btn.frame = bframe;  
    [self.btn addTarget:self action:@selector(buttonTouchDown:) forControlEvents:UIControlEventTouchDown];
    [self.btn addTarget:self action:@selector(buttonTapped:) forControlEvents:UIControlEventTouchUpInside];
    [self.btn addTarget:self action:@selector(buttonCanceled:) forControlEvents:UIControlEventTouchDragExit];
    [self addSubview:self.btn];     
}

-(void)buttonCanceled:(id)sender
{
	
}

-(void)buttonTouchDown:(id)sender
{
	
}

-(void)buttonTapped:(id)sender
{
	if (self.delegate) {
		[self.delegate multiColTableCellTapped:self];
	}
} 

-(void)setFrame:(CGRect)aFrame
{
	[super setFrame:aFrame];
}
  
@end
